<html>
  <head>
    <link rel="stylesheet" type="text/css" href="/css/c3.css">
  </head>
  <body>
    <div id="chart1"></div>
    <button onclick="load()">Load</button>
    <div id="chart2"></div>

    <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
    <script src="/js/c3.js"></script>
    <script>

      var chart1 = c3.generate({
        bindto: '#chart1',
        data: {
          columns: [
            generateData(100)
          ],
        },
        axis: {
          x: {
            default: [30, 60]
          }
        },
        zoom: {
          enabled: true,
          onzoomstart: function (event) {
            console.log("onzoomstart", event);
          },
          onzoomend: function (domain) {
            console.log("onzoomend", domain);
          },
        },
        subchart: { show: true }
      });

      var chart2 = c3.generate({
        bindto: '#chart2',
        data: {
          columns: [
            generateData(100)
          ],
        },
        axis: {
          x: {
            default: [30, 60]
          }
        },
        zoom: { enabled: true },
      });

      function load() {
        chart1.load({
          columns: [
            generateData(Math.random() * 1000)
          ],
        });
      }

      function generateData(n) {
        var column = ['sample'];
        for (var i = 0; i < n; i++) {
          column.push(Math.random() * 500);
        }
        return column;
      }

    </script>
  </body>
</html>
